package lesson4;

import sun.applet.AppletResourceLoader;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Demo2 {
    public static void main(String[] args) throws IOException, InterruptedException {
//        //Runtime
//        Runtime runtime = Runtime.getRuntime();
//        //execuate
//        //runtime.exec("calc");
//        Process process = runtime.exec("C:\\Program Files (x86)\\Google\\Chrome\\Application\\Chrome.exe");
//        //Process process = runtime.exec("D:\\Program Files\\Tencent\\QQ\\Bin\\QQScLauncher.exe");
//
//        Thread.sleep(5*1000);
//        process.destroyForcibly();
        Runtime r = Runtime.getRuntime();
        Process p;
        try {
            //运行一个应用程序文件 返回该程序的运行示例(进程)
            p = r.exec("ping 127.0.0.1 -t");
            BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream(), "gbk"));
            String inline;
            while ((inline = br.readLine()) != null) {
                String string = new String(inline.getBytes());
                System.out.println(string);
            }
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }


        Runtime runtime2 = Runtime.getRuntime();


    }
}
